import type { UserStateType } from '@/api/user';
import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
	state: ():UserStateType => ({ 
			dict_data_map: {},
			current_user: {},
			menu_tree: [],
			button_list:[],
			perms_list: [],
			route_map:{},
			upload_map:{}
		 }),
	actions: {
		// 储存当前权限 
		setUserStoreData({
		  dict_data_map,
		  current_user,
		  menu_tree,
		  button_list,
		  perms_list,
		  route_map,
		  upload_map
		}:UserStateType) {
		  this.dict_data_map = dict_data_map;
		  this.current_user = current_user;
		  this.menu_tree = menu_tree;
		  this.button_list = button_list;
		  this.perms_list = perms_list;
		  this.route_map = route_map;
		  this.upload_map = upload_map;
		},
		// 重置当前所有数据
		resetState() {
		  this.dict_data_map = {};
		  this.current_user = {};
		  this.menu_tree = [];
		  this.button_list = [];
		  this.perms_list = [];
		  this.route_map = {}
		  this.upload_map = {}
		},
	},
});
